package opdracht3.mark.pim;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Trie {

	// fields

	private static TrieNode root;

	// constructor

	public Trie() {
		
	}

	public static void main(String[] args) {
		root = new TrieNode();
		insert("ditiseentest");
		insert("ditiseentestlalala");
		insert("aaaa");
		insert("ditwaseentest");
		
		try {
			Scanner input = new Scanner(new File("C://lorip.txt"));
			
			while(input.hasNext()) {
				insert(input.next());
			}
		} catch (FileNotFoundException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		
//		try {
//			FileInputStream fis = new FileInputStream("lorip.txt");
//			DataInputStream dis = new DataInputStream(fis);
//			BufferedReader br = new BufferedReader(new InputStreamReader(dis));
//			String line;
//			
//			
//			
//		} catch (FileNotFoundException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
		
		getWords();
	}

	// methods

	public static void insert(String word) {
		Data d = new Data(0, (char) 0, 0, word);
		root.insert(word, d);
		System.out.println(root.getCharacter());
	}
	
	public static void delete(String word) {
		root.delete(word);
	}
	
	public static void getWords() {
		root.getChildren();
	}

}
